const fs = require('fs');
const beautify = require('js-beautify').js
const { codestyle } = require('../index');

const generateFile = (location, content) => {
    return new Promise((resolve, reject) => {
        try {
            let data = beautify(content, codestyle);
            fs.writeFileSync(location, data);
            resolve({ code: 1, data: 'generateFile successfully !'})
        } catch (err) {
            reject({ code : -1, data: 'generateFile error !'});
        }
    })
}

module.exports = generateFile;